﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Text;

/// <summary>
/// Summary description for KBank
/// </summary>
/// 
namespace CE.Payment
{
    public class KBank
    {
        public KBank()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public void Payment(string amount, string orderRefno, string month)
        {
            /*
            KBank - Installment Plan
            */

            string Url = "https://rt05.kasikornbank.com/pgpayment/payment.aspx";
            string formId = "myForm1";

            StringBuilder htmlForm = new StringBuilder();
            htmlForm.AppendLine("<html>");
            htmlForm.AppendLine(String.Format("<body onload='document.forms[\"{0}\"].submit()'>", formId));
            htmlForm.AppendLine(String.Format("<form id='{0}' method='POST' action='{1}'>", formId, Url));

            htmlForm.AppendLine("<input type='hidden' id=MERCHANT2 name=MERCHANT2 value='401004328793001'/>");
            htmlForm.AppendLine("<input type='hidden' id=TERM2 name=TERM2 value='74402586'/>");
            htmlForm.AppendLine("<input type='hidden' id=AMOUNT2 name=AMOUNT2 value='" + amount + "'/>");   
            htmlForm.AppendLine("<input type='hidden' id=URL2 name=URL2 value='http://www.gluaygluay.com' />");

            htmlForm.AppendLine("<input type='hidden' id=RESPURL name=RESPURL value='' />");

            htmlForm.AppendLine("<input type='hidden' id=IPCUST2 name=IPCUST2 value='' />");
            htmlForm.AppendLine("<input type='hidden' id=DETAIL2 name=DETAIL2 value='Test Payment' />");

            htmlForm.AppendLine("<input type='hidden' id=INVMERCHANT name=INVMERCHANT value='000000009999' />");
            htmlForm.AppendLine("<input type='hidden' id=Payterm2 name=Payterm2 value='" + month + "' />");


            //htmlForm.AppendLine("<input type='submit' id='btnSubmit' name='submit' />");

            htmlForm.AppendLine("</form>");
            htmlForm.AppendLine("</body>");
            htmlForm.AppendLine("</html>");

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(htmlForm.ToString());
            HttpContext.Current.Response.End();
        }
    }
}

